package com.aws.config;

import com.amazonaws.ClientConfiguration;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import com.amazonaws.services.s3.model.Bucket;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @description:
 * @author: libugu@cskaoyan.com
 * @date 2024/1/15 - 11:06
 */
@Configuration
public class AwsConf {
    String accessKey = "AKIAVRUVULBRC2MI626A";
    String secretKey = "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";
    String region = "ap-northeast-1";  // 替换为你的S3桶所在的地区

    @Bean
    public AmazonS3 amazonS3(){
        ClientConfiguration clientConfiguration = new ClientConfiguration();
        clientConfiguration.setRequestTimeout(600*1000);
       BasicAWSCredentials basicAWSCredentials = new BasicAWSCredentials(accessKey, secretKey);
       AmazonS3 build = AmazonS3ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(basicAWSCredentials))
               .withClientConfiguration(clientConfiguration).withRegion(region).build();
        return build;
   }
}
